package lab01.test03;

import java.util.Scanner;

public class Main {

    static int transfer(int n, int base) {

        if (n == 0)
            return 0;

        return n % base + transfer(n / base, base);

    }

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

        Integer sum = 0;
        System.out.println(transfer(n, 7));
    }
}
